package org.example.exception;

import lombok.Data;
import org.example.enums.ResponseCodeEnum;

/**
 * @author: wf
 * @create: 2020/10/23 13:40
 * @description: 业务执行错误-自定义异常
 */
@Data
public class BizException extends RuntimeException{
    private static final long serialVersionUID = 914358896094081637L;
    
    /**
     * 状态码
     * @see ResponseCodeEnum
     */
    private int code;
    /**
     * 提示信息
     */
    private String msg;
    /**
     * 返回数据
     */
    private Object data;

    /**
     * @param code 状态码 {@link ResponseCodeEnum}
     */
    public BizException(int code) {
        super();
        this.code = code;
    }

    /**
     * @param code 状态码 {@link ResponseCodeEnum}
     * @param msg 错误原因
     */
    public BizException(int code, String msg){
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    /**
     * @param code 状态码 {@link ResponseCodeEnum}
     * @param msg
     * @param data
     */
    public BizException(int code, String msg, Object data) {
        super(msg);
        this.code = code;
        this.data = data;
        this.msg = msg;
    }
}
